//
//  ideaOne.m
//  EquiriesProject
//
//  Created by qianfeng on 15/11/1.
//  Copyright (c) 2015年 HXH. All rights reserved.
//

#import "ideaOne.h"

@implementation ideaOne
{
    UITextField * textField1;
    UITextField * textField2;
    UIScrollView * _scroller;
}

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:1];
        
        [self createScroller];
        
        [self createTextField];
    }
    return self;
}

//创建scrollerView
-(void)createScroller
{
    _scroller = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, Width, Height)];
    _scroller.backgroundColor = [UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:1];
    _scroller.contentSize = CGSizeMake(Width, Height+40);
    _scroller.delegate = self;
    [self addSubview:_scroller];
    
}


-(void)createTextField
{
    textField1 = [[UITextField alloc]initWithFrame:CGRectMake(10, 0, Width-20, 40)];
    textField1.placeholder = @"请输入您的QQ,邮箱或手机号";
    textField1.layer.cornerRadius = 10;
    textField1.layer.masksToBounds = YES;
    textField1.borderStyle = UITextBorderStyleRoundedRect;
    [_scroller addSubview:textField1];
    
    textField2 = [[UITextField alloc]init];
    textField2.placeholder = @"我想说......";
    
    textField2.layer.cornerRadius = 10;
    textField2.layer.masksToBounds = YES;
    textField2.borderStyle = UITextBorderStyleRoundedRect;
    [_scroller addSubview:textField2];
    UIButton * button = [[UIButton alloc]init];
    [button setTitle:@"发送" forState:UIControlStateNormal];
    button.backgroundColor = [UIColor redColor];
    button.layer.cornerRadius = 10;
    button.layer.masksToBounds = YES;
    [_scroller addSubview:button];
    [button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_scroller.mas_bottom).offset(Height-110);
        make.right.equalTo(self.mas_right).offset(-10);
        make.width.equalTo(@60);
        make.height.equalTo(@40);
        
    }];
    [textField2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(10);
        make.top.equalTo(_scroller.mas_bottom).offset(Height-110);
        make.right.equalTo(button.mas_left).offset(-10);
        make.height.equalTo(@40);
    }];
    
    
    
}

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [textField1 resignFirstResponder];
    [textField2 resignFirstResponder];
}

@end
